<?php
/**
 * Created by PhpStorm.
 * User: gabriel
 * Date: 2018/12/6
 * Time: 6:22 PM
 */
namespace Api\Common;

use Common\JsonApi;
use Common\Request;
use Common\RequestApi;
use Common\Response;
use Common\ResponseApi;
use Common\STS;

class GetSTSRequestData extends RequestApi{
}

class GetSTSResponseData extends ResponseApi{
  public $accessKeyId;
  public $accessKeySecret;
  public $expiration;
  public $securityToken;
}

class GetSTS extends JsonApi {
  protected function run(Request $request, Response $response) {
    $token = new STS("testID");
    $res = $token->getToken("acs:ram::1397719802165840:role/sts-test",3600);
    $response->data = new GetSTSResponseData();
    $response->data->accessKeyId = $res->accessKeyId;
    $response->data->accessKeySecret = $res->accessKeySecret;
    $response->data->expiration = $res->expiration;
    $response->data->securityToken = $res->securityToken;
  }
}